<!DOCTYPE html>
<html lang="en">
<include file="CommonSidebar:common-head"/>
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<link href="__PUBLIC__/LoadPading/LoadPading.css" rel="stylesheet">
<style>
    #qrcode canvas {
        width: 100%;
        height: 100%;
    }
</style>
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">发布有赞商品</h1>
            </div>
        </div>

        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                            <div class="panel panel-default">
                                <div class="panel-heading" role="tab" id="headingOne">
                                    <h4 class="panel-title">
                                        <a role="button" data-toggle="collapse" data-parent="#accordion"
                                           href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                            发布有赞商品
                                        </a>
                                    </h4>
                                </div>
                                <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"
                                     aria-labelledby="headingOne">
                                    <div class="panel-body">
                                        <form id="editStoreForm" action="{:U('Goods/AddYZGoods')}"
                                              class="form-horizontal"
                                              method="post">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品名称</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="title"
                                                           value="测试商品">
                                                </div>
                                                <label class="col-sm-2 control-label">商品单位:</label>

                                                <div class="col-sm-3">
                                                    <select class="form-control" name="unit_id">
                                                        <option value="1">件</option>
                                                        <option value="2" selected="selected">盒</option>
                                                        <option value="3">袋</option>
                                                        <option value="4">瓶</option>
                                                        <option value="5">包</option>
                                                        <option value="6">条</option>
                                                        <option value="7">罐</option>
                                                        <option value="8">个</option>
                                                        <option value="9">桶</option>
                                                        <option value="10">箱</option>
                                                        <option value="11">双</option>
                                                        <option value="12">套</option>
                                                        <option value="13">块</option>
                                                        <option value="14">顶</option>
                                                        <option value="15">辆</option>
                                                        <option value="16">张</option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">有赞平台商品分类</label>

                                                <div class="col-sm-3">
                                                    <select class="form-control" name="cid">
                                                        <option value="10000005" selected="selected">其他</option>
                                                    </select>
                                                </div>

                                                <label class="col-sm-2 control-label">店铺商品分类</label>

                                                <div class="col-sm-3">
                                                    <select class="form-control" name="tag_ids">
                                                        <option value="95015440" selected="selected">其他</option>
                                                        <option value="97258455">6月普药</option>
                                                        <option value="97129880">厂家活动</option>
                                                        <option value="96853225">活动赠品</option>
                                                        <option value="95589952">凑单</option>
                                                        <option value="95558109">普药（新品）</option>
                                                        <option value="95409442">爆品限量</option>
                                                        <option value="95228935">彩虹计划</option>
                                                        <option value="95015441">控销产品</option>

                                                        <option value="95610859">test (测试)</option>
                                                        <option value="95571432">其他(测试) </option>
                                                        <option value="95571431">下装(测试)</option>
                                                        <option value="95571430">上装(测试)</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">起批数</label>

                                                <div class="col-sm-3">
                                                    <input type="number" class="form-control" name="start_wholesale_num"
                                                           min="1" max="100" value="3"></div>
                                                <label class="col-sm-2 control-label">零售价:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="retail_price"
                                                           value="10">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">风格标签</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="labels"
                                                           value="测试标签1,测试标签2">
                                                </div>
                                                <label class="col-sm-2 control-label">是否会员可见:</label>

                                                <div class="col-sm-3">
                                                    <select class="form-control" name="level_id">
                                                        <option value="1">是</option>
                                                        <option value="0">否</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">是否市场可见</label>

                                                <div class="col-sm-3">
                                                    <select class="form-control" name="is_market_hide">
                                                        <option value="1">是</option>
                                                        <option value="0">否</option>
                                                    </select>
                                                </div>
                                                <label class="col-sm-2 control-label">是否上架:</label>

                                                <div class="col-sm-3">
                                                    <select class="form-control" name="is_display">
                                                        <option value="1">是</option>
                                                        <option value="0">否</option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">是否通知进货商</label>

                                                <div class="col-sm-3">
                                                    <select class="form-control" name="is_auto_publish_feeds">
                                                        <option value="1">是</option>
                                                        <option value="0">否</option>
                                                    </select>
                                                </div>
                                                <label class="col-sm-2 control-label">展示价</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="price"
                                                           value="10">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品图片</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="image_urls"
                                                           value="http://pic49.nipic.com/file/20140927/19617624_230415502002_2.jpg">
                                                </div>
                                                <label class="col-sm-2 control-label">商品编号:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="goods_no"
                                                           value="00001">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品描述</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="desc"
                                                           value="商品描述商品描述商品描述商品描述">
                                                </div>
                                                <label class="col-sm-2 control-label">总库存:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="quantity"
                                                           value="1000">
                                                </div>
                                            </div>

                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">商品简介:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="intro"
                                                           value="商品简介商品简介商品简介商品简介">
                                                </div>
                                            </div>
                                            <HR/>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"
                                                       style="font-size: 18px;color: red">Sku信息:</label>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">规格:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="sku1"
                                                           value="0.126*50粒/盒">
                                                </div>
                                                <label class="col-sm-2 control-label">规格价:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="sku2"
                                                           value="10">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">国药准字:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="sku3"
                                                           value="国药准字H20102345">
                                                </div>
                                                <label class="col-sm-2 control-label">厂家名称:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="sku4"
                                                           value="上海建坤制药公司">
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <div class="col-sm-2 col-sm-offset-2">
                                                    <button type="submit" class="btn btn-block btn-primary">保存</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
    <!-- /#page-wrapper -->

</div>


<!-- 选择图片弹窗 -->
<div class="modal fade" id="imgModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">我的文件</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-3">
                            <div style="display:none">{$search}</div>
                            <input hidden id="FolderID" value="">

                            <div id="Folders-content" class="list-group">

                            </div>
                        </div>
                        <div class="col-md-9">
                            <div class="row" id="file-content">


                            </div>
                            <div class="row ">
                                <div class="col-xs-12 text-center">
                                    {$show}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-upload btn-primary">本地上传</button>
                <button type="button" class="btn btn-img-ok btn-primary">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

<!-- 图片本地上传弹窗 -->
<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">上传图片</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xs-12">
                            <form id="uploadImg" action="" enctype="multipart/form-data">
                                <div class="form-group">
                                    <label>选择图片</label>

                                    <div id="imgdiv" style="margin: 10px 0">
                                        <img id="imgShow" class="img-responsive" width="200"/>
                                    </div>
                                    <input type="file" name="pic" id="up_img">

                                    <p class="help-block">仅支持jpg、gif、png三种格式, 大小不超过1MB</p>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-upload-ok btn-primary">上传</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


<!--修改地址弹窗-->
<div class="modal fade" id="addressModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">选择地址</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row" id="image-item-list">
                        <div class="col-xs-12 form-horizontal">
                            <div class="form-group">
                                <label class="col-xs-12">收货地址</label>
                            </div>
                            <div class="form-group" id="showAddress">

                            </div>
                            <div class="form-group">
                                <label class="col-xs-12">详细地址</label>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-12">
                                    <input name="DETAIL" type="text" class="form-control"
                                           value="">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn edit-address-ok btn-primary">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>

        </div>
    </div>
</div>

<!--绑定二维码弹窗-->
<div class="modal fade" id="wechatModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">打开微信扫描二维码</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xs-12">
                            <div id="qrcode" style="width: 200px;height: 200px;margin: 0 auto">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="window.location.reload();">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


<include file="CommonSidebar:common-script"/>
<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/uploadPreview.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.form.min.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.qrcode.min.js"></script>
<script src="__PUBLIC__/js/address.js"></script>
<script src="__PUBLIC__/LoadPading/LoadPading.js"></script>
<script>
    $(function () {
        var url = "{:C('URL_ROOT')}Admin/BindingWX/getCode?mid={:outS('unid')}";
        $('#qrcode').qrcode(url);
    });
    <!--图片预览-->
    new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});
    new addressLinkage($("#showAddress"));//显示地址栏

    var $imgActive = $(".store-logo");
    var imgUrl;
    var unid;
    var workpath = "/./";
    //店铺LOGO修改事件
    $(".edit-img").click(function () {
        //成功获取数据则打开弹窗
        $("#imgModal").modal();
    });

    //选择规格图片
    $(document).on("click", ".image-item", function () {
        $(this).addClass("active").parent("div").siblings("div").find("img").removeClass("active");
        imgUrl = $(this).attr("src");
        unid = $(this).attr("data-unid");
    });
    //双击选择规格图片
    $(document).on("dblclick", ".image-item", function () {
        $(this).addClass("active").parent("div").siblings("div").find("img").removeClass("active");
        imgUrl = $(this).attr("src");
        unid = $(this).attr("data-unid");

        $imgActive.attr("src", imgUrl);
        $imgActive.next("input").val(imgUrl);
        $("#imgModal").modal("hide");
    });

    //打开上传图片弹窗
    $(".btn-upload").click(function () {
        $("#uploadModal").modal();
        $("#imgModal").modal("hide");
    });

    //确定选择图片
    $(".btn-img-ok").click(function () {
        $imgActive.attr("src", imgUrl);
        $imgActive.next("input").val(imgUrl);
        $("#imgModal").modal("hide");
    });
    //上传图片
    $(".btn-upload-ok").click(function () {
        var url = workpath + "Admin/Picasa/AJAXUpload";
        var options = {
            type: 'post',
            url: url,
            dataType: 'text',
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                var json_obj = JSON.parse(data);
                imgUrl = json_obj.THUMBPICPATH;
                unid = json_obj.UNID;
                imgUrl = workpath + imgUrl;
                $imgActive.attr("src", imgUrl);
                $imgActive.next("input").val(imgUrl);
                $("#uploadModal").modal("hide");
                UpdateFolders();
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                alert("上传失败");
            }
        };
        $("#uploadImg").ajaxSubmit(options);
    });


    //获取中文地址
    function getArea(data) {
        data = data.replace(/'/g, "\"");//把单引号换双引号
        data = JSON.parse(data); //可以将json字符串转换成json对象
        data = data.area;
        return data;
    }

    //选择地址确认按钮事件
    $(".edit-address-ok").click(function () {
        var $elem = $(this);
        var province = $elem.parents(".modal").find("[name='PROVINCES']").val();
        var city = $elem.parents(".modal").find("[name='CITYS']").val();
        var area = $elem.parents(".modal").find("[name='AREAS']").val();
        var detail = $elem.parents(".modal").find("[name='DETAIL']").val();

        province = getArea(province); //可以将json字符串转换成json对象
        city = getArea(city); //可以将json字符串转换成json对象
        area = getArea(area); //可以将json字符串转换成json对象

        $("[name='address']").val(province + city + area + detail);
        $("#addressModal").modal("hide");
    });

    /*初始化分页类*/
    var LoadObj = new LoadPading(12, 3, "{:U('Picasa/PicasaPading')}", 5, true);

    function UpdateFolders() {
        /*获取文件夹列*/
        $.post(workpath + "Admin/Picasa/Folders", {}, function (data) {
            var folder = eval(data);
            var html = '';
            for (var i = 0; i < folder.length; i++) {
                html += '<a href="#" data-id="';
                if (folder[i]['unid'] == '') {
                    html += folder[i]['unid'];
                    html += '" class="list-group-item active">';
                } else {
                    html += folder[i]['unid'];
                    html += '" class="list-group-item">';
                }
                html += folder[i]['filename'];
                var number = folder[i]['sum'] == null ? 0 : folder[i]['sum'];
                html += '<span class="badge">' + number;
                html += '</span></a>';
            }
            ;
            $("#Folders-content").html(html);
            click_search();
        });
        /*获取文件夹列*/
    }


    /*文件夹点击JS*/
    $(document).on("click", ".list-group-item", function () {
        $('#Loadsearch').val($(this).attr("data-id"));
        $(this).addClass("active").siblings(".list-group-item").removeClass("active");
        click_search();
    });

    $(function () {
        /*图片分页设置*/
        LoadObj.initFun_Load();

        LoadPading.prototype.setDateScene = function (useSet) {
            var html = '';
            for (var i = 0; i < useSet.length; i++) {
                html += '<div class="col-md-3">';
                html += '<img class="image-item img-responsive"';
                if ('__ROOT__' == '') {
                    html += 'src="/' + useSet[i]['thumbpicpath'] + '" ';
                } else {
                    html += 'src="__ROOT__' + useSet[i]['thumbpicpath'] + '" ';
                }

                html += 'data-unid="' + useSet[i]['unid'] + '"></div>';
            }
            $("#file-content").html(html);
        };
        UpdateFolders();
    });


    //修改点击事件
    $(document).on("click", ".edit-store", function () {
        var $elem = $(this);
        var $input = $elem.parents(".col-sm-1").prev(".col-sm-3").find("input");
        if ($elem.hasClass("active")) {
            $input.attr("readonly", true);
            $elem.html("修改");
            $elem.removeClass("active");
        } else {
            $input.attr("readonly", false);
            $elem.html("确认");
            $elem.addClass("active");
        }
    });
</script>


</body>

</html>
